<template>
    <div class="data-set">
        <div class="wrapper">
            <div class="data-wrapper">
                <div class="title">请选择要管理的数据集</div>
                <div class="no-data" v-if="dataList.length==0">未查询到相关数据集，<span @click="$router.push({path:'/constant'})">前往常量管理</span></div>
                <div class="data-list" v-else>
                    <div @click="select(item)" class="data-item" v-for="(item, index) in dataList" :key="'item' + index">{{item.data_set_name}}</div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import DataSetService from '../../services/DataSetService.js'
import bus from '../common/bus';
export default {
    data() {
        return {
            service: new DataSetService,
            dataList:[]
        }
    },
    created() {
        this.getList();
    },
    methods: {
        async getList() {
            let result = await this.service.getAll();
            if ( result.code == 200 ) {
                this.dataList = result.data;
            } else {
                this.dataList = [];
            }
        },
        select( dataItem ) {
            bus.$emit('dataSet', dataItem);
            window.localStorage.setItem('zhdq_gismanage_dataset', JSON.stringify(dataItem));
            this.$router.push({path:'/TaskMangeList'});
        }
    }
}
</script>

<style scoped>
/* .data-set{
    position: relative;
} */
.wrapper{
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .4)
}
.data-wrapper{
    width: 1050px;
    min-height: 500px;
    border: 1px solid #e2e2e2;
    background: #fff;
    margin: 0 auto;
    margin-top: 140px;
}
.title{
    font-size: 16px;
    line-height: 50px;
    border-bottom: 1px solid #e2e2e2;
    text-align: center;
}
.data-list{
   display: flex;
   flex-wrap: wrap;
   padding: 20px 0;
}
.data-item{
    display: block;
/*     float: left; */
    width: 200px;
    height: 70px;
    border:1px solid #e2e2e2;
    line-height: 70px;
    text-align: center;
    background: #fff;
    box-shadow: 0 0 5px 0 #e2e2e2;
    margin: 20px 30px;
    cursor: pointer;
}
.data-item:hover{
    background: #409EFF;
    color: #fff;
    opacity: 0.7;
}
.no-data{
    text-align: center;
    margin-top: 30px;
}
.no-data span{
    color: #3f8def;
    text-decoration: underline;
    cursor: pointer;
}
</style>
